package cn.com.se.设计模式.单例模式;

/**
 * 饿汉单例
 */
public class Single2 {

    private static Single2 single2 = null;

    private Single2() {
    }

    /**
     * 饿汉单例
     */
    public synchronized static Single2 test() {
        if (single2 == null) {
            single2 = new Single2();
        }
        return single2;
    }

    public void print(){
        System.out.println("饿汉单例模式");
    }

}
